Skip to content

[Fix/refresh-token]#61

Merged
ekgns33 merged 2 commits intomainfrom
fix/fix-login-refresh-token-save
Apr 19, 2025
Merged

[Fix/refresh-token]#61
ekgns33 merged 2 commits intomainfrom
fix/fix-login-refresh-token-save

Conversation

@ekgns33
Copy link
Copy Markdown
Contributor

@ekgns33 ekgns33 commented Apr 19, 2025

#60 에서 적용되지 않은 저장로직이 존재하여 revert 후 다시 작업했습니다.

Summary by CodeRabbit

  • New Features
    • Improved login handling for Apple and Kakao logins by securely storing refresh tokens upon successful authentication.
  • Chores
    • Updated configuration to allow JWT expiration times to be set via environment variables, with sensible defaults for different environments.

@ekgns33 ekgns33 added bug Something isn't working enhancement New feature or request labels Apr 19, 2025
@ekgns33 ekgns33 self-assigned this Apr 19, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2025

Walkthrough

A new method for storing refresh tokens was added to the authentication service. The Apple and Kakao login handlers were updated to use this method, ensuring refresh tokens are explicitly saved after user authentication. The system configuration was also modified to allow JWT expiration and refresh expiration values to be set via environment variables, with defaults provided for both development and production profiles. No other logic or error handling was changed in these updates.

Changes

File(s) Change Summary
src/main/java/org/runimo/runimo/auth/service/TokenRefreshService.java Added putRefreshToken(String userId, String refreshToken) method to store refresh tokens with expiration.
src/main/java/org/runimo/runimo/auth/service/apple/AppleLoginHandler.java
src/main/java/org/runimo/runimo/auth/service/kakao/KakaoLoginHandler.java
Added TokenRefreshService dependency and updated login methods to store refresh tokens after authentication.
src/main/resources/application.yml Changed JWT expiration values to use environment variables with defaults for both dev and prod profiles.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LoginHandler
    participant TokenRefreshService
    participant AuthResult

    User->>LoginHandler: Initiate login (Apple/Kakao)
    LoginHandler->>LoginHandler: Validate credentials
    LoginHandler->>LoginHandler: Generate JWT token pair
    LoginHandler->>TokenRefreshService: putRefreshToken(userId, refreshToken)
    TokenRefreshService-->>LoginHandler: Store refresh token
    LoginHandler->>AuthResult: Return authentication result
    AuthResult-->>User: Provide tokens
Loading

Possibly related PRs

  • Run-Us/Runimo#60: Adds a saveRefreshToken method to TokenRefreshService and uses it in the signup flow, similar to the new putRefreshToken method used in login handlers in this PR.

Poem

A hop and a skip, a token to keep,
Now refreshes are stored, no secrets to seep.
Handlers for Apple and Kakao in tow,
With configs now flexible, the system will grow.
🥕 The code hops ahead, secure and bright,
Refreshing our tokens deep into the night!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 209fe7e and 3cc062b.

📒 Files selected for processing (4)
  • src/main/java/org/runimo/runimo/auth/service/TokenRefreshService.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/service/apple/AppleLoginHandler.java (3 hunks)
  • src/main/java/org/runimo/runimo/auth/service/kakao/KakaoLoginHandler.java (3 hunks)
  • src/main/resources/application.yml (2 hunks)
🔇 Additional comments (9)
src/main/resources/application.yml (2)

101-103: Environment-configurable JWT expiration times with sensible defaults

The JWT expiration values now use environment variables with fallback defaults, allowing for dynamic configuration without code changes. I noticed the default token expiration time for development decreased from 5 minutes to 3 minutes, while the refresh token expiration increased from 1 hour to 24 hours.


122-124: Production token expiration values configured correctly

Good implementation of environment variables with defaults for production. The access token lifetime has been increased slightly (from 1 hour to 1.67 hours), while the refresh token duration remains at 7 days.

src/main/java/org/runimo/runimo/auth/service/TokenRefreshService.java (1)

24-26: Token storage method implemented correctly

The new putRefreshToken method correctly stores refresh tokens with the appropriate expiration duration. This implements the missing storage logic mentioned in the PR description.

src/main/java/org/runimo/runimo/auth/service/kakao/KakaoLoginHandler.java (3)

13-13: Import for new dependency added correctly

The TokenRefreshService import is correctly added to support the new functionality.


32-32: Dependency injection for TokenRefreshService added

Correctly added TokenRefreshService as a required dependency via constructor injection.


56-58: Refresh token properly stored after successful login

The refresh token is now explicitly stored in the cache using the TokenRefreshService, resolving the storage issue mentioned in the PR description.

src/main/java/org/runimo/runimo/auth/service/apple/AppleLoginHandler.java (3)

14-14: Import for TokenRefreshService added correctly

The TokenRefreshService import is correctly added to support the new functionality.


32-32: TokenRefreshService dependency correctly injected

Correctly added TokenRefreshService as a required dependency via constructor injection.


65-67: Refresh token properly stored after successful login

The refresh token is now explicitly stored using the TokenRefreshService. This ensures consistent refresh token handling between Apple and Kakao login flows.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ekgns33 ekgns33 merged commit 6f3c4f3 into main Apr 19, 2025
3 checks passed
@ekgns33 ekgns33 deleted the fix/fix-login-refresh-token-save branch April 19, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant